<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"DD-6-1");
mysql_select_db($database_con_gl, $con_gl);
$query_klas = "SELECT kd, klasifikasi, keterangan, neraca, ruglab, tipe FROM gl_klas where `tipe` <>6 AND `tipe` <>7 ORDER BY kd,klasifikasi ASC";
$klas = mysql_query($query_klas, $con_gl) or die(mysql_error());
$row_klas = mysql_fetch_assoc($klas);
$totalRows_klas = mysql_num_rows($klas);
// ---
mysql_select_db($database_con_gl, $con_gl);
$query_gudang = "SELECT id, gudang FROM gl_gudang";
if(!strstr($_SESSION[akses],'A-1-4')) {
	$query_gudang .= " where id='$_SESSION[lokasi]'";
}
$query_gudang .=" ORDER BY gudang ASC";
$gudang = mysql_query($query_gudang, $con_gl) or die(mysql_error());
$row_gudang = mysql_fetch_assoc($gudang);
$totalRows_gudang = mysql_num_rows($gudang);
?>
<link href="ccss/ui.datepicker.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript">
<!--
$(function()
      {
        $('.calendar').datepicker({
            appendText : "",
            dateFormat : 'yy/mm/dd'
          });
      });
	  
</script>
<script type="text/javascript" src="js/ajax_data.js"></script>
<script type="text/javascript">
$(document).ready(function() {

	$().ajaxStart(function() {
		$('#loading').show();
		$('#result').hide();
	}).ajaxStop(function() {
		$('#loading').hide();
		$('#result').fadeIn('slow');
	});

	$('#add').submit(function() {
		$.ajax({
			type: 'POST',
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(data) {
				$('#result').html(data);
			}
		})
		return false;
	});
  $('#result').click(function(){
  $(this).hide();
  });
})
</script>
<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>
<div id="result" style="display:none;"></div>
<h1>Tambah Transaksi Harian </h1>
<form action="proses/transaksiharian.php?act=add" method="POST" name="add" id="add">
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
    <tr>
      <td colspan="2"></td>
    </tr>
    <tr>
      <td width="14%" align="right" valign="top">No. Referensi*: </td>
      <td width="86%" valign="top"><div id="refDiv"><label>
        <input name="noreferensi" type="text" id="noreferensi" value="TH<?php echo time();?>" size="20" maxlength="20" onchange="cekReferensi(this.value);"/>
      </label></div></td>
    </tr>
    <tr>
      <td align="right" valign="top">Lokasi Kantor* :</td>
      <td valign="top"><label>
        <select name="gudang" id="gudang">
          <?php
do {  
?>
          <option value="<?php echo $row_gudang['id']?>"><?php echo $row_gudang['gudang']?></option>
          <?php
} while ($row_gudang = mysql_fetch_assoc($gudang));
  $rows = mysql_num_rows($gudang);
  if($rows > 0) {
      mysql_data_seek($gudang, 0);
	  $row_gudang = mysql_fetch_assoc($gudang);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr>
      <td align="right" valign="top">Tanggal* : </td>
      <td valign="top"><label>
        <input name="tanggal" type="text" class="calendar" id="tanggal" value="<?php echo date("Y/m/d"); ?>" size="20" maxlength="15"/>
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right">Keterangan : </td>
      <td><label>
        <textarea name="keterangan" cols="40" rows="2" id="keterangan">Daftar Jurnal Transaksi Harian</textarea>
      </label></td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td><div id="ajaxDiv">
        <table width="100%" border="0" cellspacing="0" cellpadding="5" class="datatable">
          <tr>
            <th width="10%" align="center"><strong>Kode</strong></th>
            <th width="30%" align="center"><strong>Akun</strong></th>
            <th width="10%" align="center"><strong>Debet</strong></th>
            <th width="10%" align="center"><strong>Kredit</strong></th>
            <th width="30%" align="center"><strong>Transaksi</strong></th>
            <th width="10%" align="center"><strong>Aksi</strong></th>
          </tr>
          <tr valign="top">
            <td width="10%" align="center" style="background:#FFF;border:none;"><div id="kodeDiv"><label>
              <input name="akunkd" type="text" id="akunkd" size="10" maxlength="10" onchange="cekAkun(this.value);"/>
            </label></div></td>
            <td width="30%" align="center" style="background:#FFF;border:none;"><div id="akunDiv">
              <label>
                <select name="akun" id="akun" onchange="cekKode(this.value);">
                  <?php
do {  
?>
                  <?php
mysql_select_db($database_con_gl, $con_gl);
$query_akun = "SELECT id, akun, klasifikasi, keterangan FROM gl_akun where klasifikasi = '$row_klas[kd]' ORDER BY id,akun ASC";
$akun = mysql_query($query_akun, $con_gl) or die(mysql_error());
$row_akun = mysql_fetch_assoc($akun);
$totalRows_akun = mysql_num_rows($akun);
?>
                  <option value="" style="background:#EEEEEE; font-weight:bold;"><?php echo $row_klas['klasifikasi'];?></option>
                  <?php do { ?>
                  <option value="<?php echo $row_akun['id']?>">-<?php echo $row_akun['akun']?></option>
                  <?php } while ($row_akun = mysql_fetch_assoc($akun));?>
                  <?php
} while ($row_klas = mysql_fetch_assoc($klas));
  $rows = mysql_num_rows($klas);
  if($rows > 0) {
      mysql_data_seek($klas, 0);
	  $row_klas = mysql_fetch_assoc($klas);
  }
?>
                </select>
                </label>
            </div></td>
            <td width="10%" align="center" style="background:#FFF;border:none;"><label>
              <input name="debet" type="text" id="debet" size="10" onchange="javascript:if(this.value > 0) { this.form.kredit.value='';}else{ alert('Value invalid !!!');this.value='';}"/>
            </label></td>
            <td width="10%" align="center" style="background:#FFF;border:none;"><label>
              <input name="kredit" type="text" id="kredit" size="10" onchange="javascript:if(this.value > 0) { this.form.debet.value='';}else{ alert('Value invalid !!!');this.value='';}"/>
            </label></td>
            <td width="30%" align="center" style="background:#FFF;border:none;"><label>
              <textarea name="transaksi" cols="35" rows="2" id="transaksi"></textarea>
            </label></td>
            <td width="10%" align="center" style="background:#FFF;border:none;">
                  <label>
                  <input name="add" type="button" id="add" value="&nbsp;" onclick="ajaxManageTransaksi('Tambah');" class="checkbutton" title="Tambah Transaksi"/>
                </label></td>
          </tr>
        </table>
      </div></td>
    </tr>
    <tr>
      <td align="left"><em>*Harus diisi</em></td>
      <td><input name="jenis" type="hidden" id="jenis" value="1" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="add">
  <input type="hidden" name="MM_insert" value="add">
</form>
